package com.lizhi.menu.common.entity;

import com.lizhi.menu.common.enums.ResultCode;
import org.springframework.lang.NonNull;

/**
 * 自定义异常，项目中所有自定义运行时异常应继承该类
 *
 * @author lizhi
 */
public class ApplicationException extends RuntimeException {

    private final ResultCode responseCode;

    public ApplicationException(@NonNull ResultCode responseCode) {
        this(responseCode, responseCode.getMsg());
    }

    public ApplicationException(@NonNull ResultCode responseCode, Throwable cause) {
        super(responseCode.getMsg(), cause);
        this.responseCode = responseCode;
    }

    public ApplicationException(@NonNull ResultCode responseCode, String message) {
        super(message);
        this.responseCode = responseCode;
    }

    public ApplicationException(@NonNull ResultCode responseCode, String message, Throwable cause) {
        super(message, cause);
        this.responseCode = responseCode;
    }

    public ResultCode getResponseCode() {
        return responseCode;
    }

}
